package org.numanint.code;

import java.util.ArrayList;
import java.util.HashMap;


public class HibernateCfgGenerator extends Generator {
	public HibernateCfgGenerator(GeneratorProperties p){
		super(p);
	}
	public void generator(ReverseEngineer reveng) throws Exception{	
			HashMap<String,Object> data = new HashMap<String,Object>();
			ArrayList<String> resourceArray = new ArrayList<String>();
			for(int i=0;i<reveng.getTableClasss().length;i++){	
				String className = ConventUtils.t2c(reveng.getTableClasss()[i].getTableName());		
				resourceArray.add(getProperties().getPojoPkgName().replace('.','/')+"/"+className+".hbm.xml");
			} 
			if(getProperties().getPojoPkgName()!=null) 
				setOutputDir(getOutputDir()+getProperties().getPojoPkgName().replace('.',System.getProperty("file.separator").charAt(0)));
			HashMap<String,Object> resourceMap=new HashMap<String,Object>();
			resourceMap.put("resource",resourceArray);
			data.put("hibernate.cfg.xml", resourceMap);
			super.setData(data);
			super.generator();
		
	}	
}
